home *** CD-ROM | disk | FTP | other *** search
/ System Booster / System Booster.iso / Texteditors / Origami / Sources / src / origami / origami.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-09-27  |  31.8 KB  |  1,182 lines

  1. /* origami.h - contains some definitions and a lot of prototypes */
  2.  
  3. /*{{{}}}*/
  4. /*{{{  includes*/
  5. #include "default.h"
  6. #include <h/os.h>
  7. #include <lib/ori_bool.h>
  8. /*{{{  h/keys.h*/
  9. #if defined(GETTK_C) || defined(I_GETTK_C)
  10. #  define BIND_CONST
  11. #endif
  12. #include <h/keys.h>
  13. #if defined(GETTK_C) || defined(I_GETTK_C)
  14. #  undef BIND_CONST
  15. #endif
  16. /*}}}  */
  17. #include <h/lg.h>
  18. #include "exit.h"
  19. #include <h/getmsg.h>
  20. /*}}}  */
  21.  
  22. #define private static
  23. #define public
  24.  
  25. /*{{{  constants*/
  26. /*{{{  shifting lines*/
  27. #ifdef LOOP_C
  28. #  define SHIFT_PART(width) (((width)/8)+1)
  29. #endif
  30. /*}}}  */
  31. /*{{{  status line length*/
  32. #ifdef DISPLAY_C
  33. #  ifdef WINDOW_TITLE_CHANGE
  34. #     define WIN_TITLE_LENGTH(w) (((w)*3)/4)
  35. #  endif
  36. #endif
  37. #ifdef LOOP_C
  38. #  define MIN_SG_TITLE 8
  39. #endif
  40. /*}}}  */
  41. /*{{{  terminal i/o*/
  42. #ifdef SCREEN_C
  43. #  define M_RP_LIMIT            8  /* use rp, if > M_PUT_LIMIT chars */
  44. #  define M_DIR_RP_LIMIT       16  /* simulate rp ' ' by DC/IC */
  45. #endif
  46. #ifdef USE_SCRBUFF
  47. #  ifdef SCRBUFF_C
  48. #     define SCROLL_INVERSE(wx,ws) ((wx)>(9*(ws))/16)
  49.                                    /* scroll remaining, if wide enough */
  50. #     define FL_SHIFT_OVER      8  /* skip more equal chars, no printing */
  51. #     define FL_SHIFT_MAX       6  /* maximum number of chars to shift */
  52. #     define FL_SHIFT_SCALE     8  /* diff_lg/FL_SHIFT_SCALE= */
  53.                                    /*    max shift width for given diff len */
  54. #     define FL_NO_DL_AL(out,height) ((out)>(((height)*3)/4))
  55.                                    /* to many new lines -> no al/dl usage */
  56. #     define FL_MAX_AL_DL      16  /* up to FL_MAX_AL_DL lines added/deleted */
  57.                                    /* in one step */
  58. #  endif
  59. #  ifdef GETTK_C
  60. #     define ARG_FL_COUNT      64  /* number of rep-arg's for auto flushs */
  61. #  endif
  62. #endif
  63. #define DEF_CURSOR_LINE         4  /* default y-screen-position */
  64. /*}}}  */
  65. /*{{{  length of internal text/filename buffers*/
  66. #define BUFFERLEN ((_POSIX_PATH_MAX>LINELEN)?_POSIX_PATH_MAX:LINELEN)
  67. /*}}}  */
  68. /*}}}  */
  69. /*{{{  types*/
  70. /*{{{  language*/
  71. /*{{{  f_c_types*/
  72. typedef enum
  73.  { F_C_NONE=0,
  74.    LANGTYP
  75.    F_C_USER,
  76.    F_C_TDS,           /* this has to be the last defined language!!! */
  77.    F_C_SIZE
  78.  } f_c_types;
  79. /*}}}  */
  80. /*{{{  language_comment*/
  81. typedef struct
  82.  { struct
  83.     { unsigned char *start;
  84.       unsigned char *end;
  85.     } txt;
  86.    struct dia_lg
  87.     { int start;
  88.       int end;
  89.     } lg;
  90.    unsigned char *name;
  91.  } language_comment;
  92. /*}}}  */
  93. /*}}}  */
  94. /*{{{  fold-tags*/
  95. typedef enum
  96.  { NOT_FOLD          =1,
  97.    START_FILED       =2,
  98.    START_FOLD        =4,
  99.    END_FOLD          =8,
  100.    START_OPEN_FOLD   =16,
  101.    START_ENTER_FILED =32,
  102.    START_ENTER_FOLD  =64
  103.  } linetyp;
  104. #define FOLD_BITS 8
  105. #define FOLD_MASK ((1<<FOLD_BITS)-1)
  106. /*}}}  */
  107. /*{{{  element*/
  108. /*{{{  fold data*/
  109. typedef struct
  110.  { struct element *data, *other_end;
  111.    int close_line;
  112.    union
  113.     { struct
  114.        { unsigned char type;
  115.          unsigned char contents;
  116.          int indent;
  117.        } U1;
  118.       struct
  119.        { int old_line;
  120.          boolean v_mode;
  121.        } U0;
  122.     } UU;
  123.  } fold_data;
  124. #define DEFAULT_TYPE 0
  125. #define TEXT_CONTENTS 1
  126. /*}}}  */
  127.  
  128. typedef struct element
  129.  { int lineflags;
  130.    union
  131.     { unsigned char *dat;
  132. #     ifdef VIRTUAL
  133.          int posi;
  134. #     endif
  135.     } datas;
  136.    struct element *prec, *next;
  137.    int indent;
  138.    union
  139.     { fold_data fold;
  140.       unsigned char txt[sizeof(fold_data)];
  141.     } x;
  142.  } element;
  143.  
  144. /*{{{  flag access*/
  145. # define set_lflags(e,t,h) ((e).lineflags=((int)(t)|(int)(h)))
  146. # define set_linetyp(e,t) set_lflags(e,t,no_highlight)
  147. # define get_linetyp(e) ((linetyp)(e).lineflags&FOLD_MASK)
  148. # define test_linetyp(e,t) ((e).lineflags&(t))
  149. # define get_highlight(e) ((highlight_typ)(e).lineflags&~FOLD_MASK)
  150. /*}}}  */
  151. /*}}}  */
  152. /*{{{  change_status*/
  153. typedef enum { unchanged_file=0,changed_once,changed_file } change_status;
  154. /*}}}  */
  155. /*{{{  win_data*/
  156. typedef struct { int h;int w; } win_data;
  157. /*}}}  */
  158. /*{{{  buffer_data*/
  159. /*{{{  select modes*/
  160. typedef enum
  161.  { no_selection               = 0,
  162.    fold_selection             = 1,
  163.    lim_pseudo_fold_selection,
  164.    lim_reg_selection,
  165.    lim_block_selection,
  166.    lim_nodrawn_selection,
  167.    unmark_fold_selection,
  168.    pseudo_fold_selection      = -lim_pseudo_fold_selection,
  169.    reg_selection              = -lim_reg_selection,
  170.    block_selection            = -lim_block_selection,
  171.    nodrawn_selection          = -lim_nodrawn_selection
  172.  } sel_mod;
  173. /*}}}  */
  174. /*{{{  screen_data*/
  175. typedef struct
  176.  { int list_no;
  177.    int id;
  178.    win_data off;
  179.    win_data win;
  180.    boolean clreol;
  181.    boolean bold_stat;
  182.    win_data txt_size;
  183.    element *start;
  184.    element *end;
  185.    win_data cursor;
  186.    int shift_size;
  187.    int cur_shift_w;
  188.    int full_shift_w;
  189.    int end_level;
  190. #  ifdef MULTIPLE_SCREEN
  191.       MULTIPLE_SCREEN
  192. #  endif
  193.  } scr_dat;
  194. /*}}}  */
  195. typedef struct
  196.  { scr_dat scr;
  197.    /*{{{  fold data*/
  198.    struct
  199.     { struct f_m_str
  200.        { unsigned char txt[4][FOLD_TAG_LENGTH+1];
  201.          int o_dsp_l;
  202.          int l_dsp_l;
  203. #        define close_f txt[0]
  204. #        define file_f txt[1]
  205. #        define line_f txt[2]
  206. #        define open_f txt[3]
  207.        } str;
  208.       boolean count_comment_line;
  209.       int entered;
  210.       int enter_spaces;
  211.       element *real_head;
  212.       element *real_tail;
  213.       element *head;
  214.       element *tail;
  215.       element *End_of_fold;
  216.       element *Start_of_fold;
  217.       element *Line_after_fold;
  218.       element *current;
  219.       linetyp cur_line_typ;
  220.       element *select_ptr;
  221.     } f;
  222.    /*}}}  */
  223.    /*{{{  editing*/
  224.    struct
  225.     { int first_scr_e_pos;
  226.       int pre_scr_e_pos;
  227.       element *part_line;
  228.       boolean split_line;
  229.       boolean fold_in;
  230.       int file_no;
  231.       int makefold_indent;
  232.     } e;
  233.    /*}}}  */
  234.    /*{{{  mode data*/
  235.    struct
  236.     { sel_mod select_mode;
  237.       boolean last_no_sel;
  238.       boolean upd_sel_delayed;
  239.       boolean full_shift;
  240.       boolean hash_shift;
  241.       boolean overwrite;
  242.       boolean read_only;
  243.       boolean user_view;
  244.       change_status file_changed_status;
  245.       boolean dir_edit;
  246.       struct lg_dumb
  247.        { f_c_types typ;
  248.          struct dia_lg lg;
  249.          unsigned char lg_u_s[FOLD_COMMENT_LENGTH+1];
  250.          unsigned char lg_u_e[FOLD_COMMENT_LENGTH+1];
  251.        } dialect;
  252.     } m;
  253.    /*}}}  */
  254.    /*{{{  statusline*/
  255.    struct
  256.     { int last_x_pos;
  257.       int y_pos;
  258.     } S;
  259.    /*}}}  */
  260.  } buffer_data;
  261. /*}}}  */
  262. /*{{{  mouse_typ*/
  263. #ifdef MOUSY
  264.    typedef enum
  265.     { no_mouse=0           /* not using a mouse                           */
  266. #     ifdef XTERM
  267.          ,xterm            /* using the xterm mouse-support               */
  268. #     endif
  269. #     ifdef MGR
  270.          ,mgr              /* using the mgr mouse-support                 */
  271. #     endif
  272. #     ifdef OS_MOUSE_TAG
  273.          ,OS_MOUSE_TAG     /* this is maybe defined for os-specific mouse */
  274. #     endif
  275.       ,mouse_supports      /* this entry can be used to get the number of */
  276.                            /* known mice, it's no real mouse-support!     */
  277.     } mouse_typ;
  278. #endif
  279. /*}}}  */
  280. /*{{{  reg_types*/
  281. #ifdef REGEXP
  282.    typedef enum { no_reg,basic_reg,ext_reg } reg_types;
  283. # endif
  284. /*}}}  */
  285. /*}}}  */
  286.  
  287. /*{{{  malloc functions*/
  288. #ifndef MALLOC_DEBUG
  289. # define paket_realloc(p,x) ORIrealloc(p,x)
  290. # define paket_malloc(x) ORImalloc(x)
  291. # define paket_free(x) ORIfree(x)
  292. #else
  293. # define DEBUGGING
  294.   extern void *paket_malloc(size_t);
  295.   extern void *paket_realloc(void*,size_t);
  296.   extern void paket_free(void*);
  297. #endif
  298. /*}}}  */
  299. /*{{{  debug functions*/
  300. /*{{{  ocl debug functions*/
  301. #ifdef OCL_DEBUG
  302. # ifndef DEBUGGING
  303. #    define DEBUGGING
  304. # endif
  305.   extern void ocl_key(int);
  306.   extern void ocl_msg(char*,int);
  307.   extern void ocl_debug(int,TOKEN);
  308.   extern void ocl_get_arg_dbg(TOKEN a,char *s);
  309. #else
  310. # define ocl_key(k)
  311. # define ocl_msg(s,n)
  312. # define ocl_debug(x,y)
  313. # define ocl_get_arg_dbg(a,s)
  314. #endif
  315. /*}}}  */
  316. /*{{{  virtual debug functions*/
  317. #ifdef VIR_DEBUG
  318. # ifndef DEBUGGING
  319. #    define DEBUGGING
  320. # endif
  321.   extern void vir_debug(off_t);
  322. #else
  323. # define vir_debug(x)
  324. #endif
  325. /*}}}  */
  326. /*{{{  specify global debug functions*/
  327. #ifdef DEBUGGING
  328.   extern void start_debug(void);
  329.   extern void end_debug(void);
  330.   extern void arg_debug(char*);
  331.   extern void title_debug(unsigned char*);
  332. # define DEBUG_FEATURE "@"
  333. # ifndef DEBUG_FILE
  334. #    define DEBUG_FILE "oridebug.dat"
  335. # endif
  336. #else
  337. # define start_debug()
  338. # define end_debug()
  339. # define arg_debug(x)
  340. # define title_debug(x)
  341. # define DEBUG_FEATURE ""
  342. #endif
  343. /*}}}  */
  344. /*}}}  */
  345.  
  346. /*{{{  STRING_C*/
  347. #if defined(STRING_C) || defined(I_STRING_C)
  348. # ifdef I_STRING_C
  349. #    undef I_STRING_C
  350. # endif
  351. # ifdef REGEXP
  352. #    define re_args(x) ,x
  353.      extern boolean preg_ok;
  354.      extern unsigned char *reg_ustrstr(unsigned char*,boolean,boolean);
  355. # else
  356. #    define re_args(x)
  357. #    define get_search(x,y,z) get_search_string()
  358. # endif
  359.   extern int get_search(boolean,boolean,boolean);
  360.   extern unsigned char *strsub(unsigned char const*, int);
  361.   extern int proc_replace(int,unsigned char const*const,unsigned char*,int,int);
  362.   extern char *do_file_c(char *f);
  363. #endif
  364. /*}}}  */
  365. /*{{{  BUFFLOOP_C*/
  366. #if defined(BUFFLOOP_C) || defined(I_BUFFLOOP_C)
  367. # ifdef I_BUFFLOOP_C
  368. #    undef I_BUFFLOOP_C
  369. # endif
  370.   extern void try_unchange(void);
  371.   extern TOKEN buffer_loop(TOKEN,boolean);
  372.   extern element *deleted_lines[UNDEL_LINES];
  373.   extern int delete_ptr;
  374. # ifdef REGEXP
  375.      extern reg_types reg_type;
  376. # endif
  377. #endif
  378. /*}}}  */
  379. /*{{{  DISPLAY_C*/
  380. #if defined(DISPLAY_C) || defined(I_DISPLAY_C)
  381. # ifndef I_MAIN_C
  382. #    define I_MAIN_C
  383. # endif
  384. # define warn_delay() usleep(verbose?(unsigned long)800000L:(unsigned long)400000L)
  385. #endif
  386. #if defined(DISPLAY_C) || defined(I_DISPLAY_C)
  387. # ifdef I_DISPLAY_C
  388. #    undef I_DISPLAY_C
  389. # endif
  390.   /*{{{  highlight_typ*/
  391.   typedef enum
  392.    { no_highlight  =0,
  393.      full_highlight=1<<FOLD_BITS,
  394.      m_f_highlight =2<<FOLD_BITS,
  395.      f_m_highlight =3<<FOLD_BITS,
  396.      c_m_highlight =4<<FOLD_BITS,
  397.      c_f_highlight =5<<FOLD_BITS
  398.    } highlight_typ;
  399.   /*}}}  */
  400.   /*{{{  dsp_data*/
  401.   typedef struct dsp_modes
  402.    { int tab_size;
  403.      enum dsp_size
  404.       { tab_dsp   = -2,
  405.         ictrl_dsp = -1,
  406.         norm_dsp  =  1,
  407.         mark_dsp  =  2,
  408.         hex_dsp   =  3,
  409.         oct_dsp   =  4,
  410.         dec_dsp   =  5,
  411.         max_dsp
  412.       } base,ctrl,norm,tilde,high;
  413.      int ctrl_add;
  414.    } dsp_data;
  415.   /*}}}  */
  416.   /*{{{  TITLE_OP*/
  417.   typedef enum
  418.    { UPDTITLE=0,
  419.      PRTTITLE,
  420.      CHGTITLE,
  421.      SMALLTITLE,
  422. #    ifdef WINDOW_TITLE_CHANGE
  423.         WINTITLE,
  424. #    endif
  425.      CHGX,
  426.      CHGXY,
  427.      INCY,
  428.      DECY,
  429.      LINE_NO
  430.    } TITLE_OP;
  431.   /*}}}  */
  432. # define numb_dsp(x) ((x)>mark_dsp)
  433.   extern int on_screen(element const * const);
  434.   extern void chg_dsp_type(int);
  435.   extern enum dsp_size char_dsp_size(unsigned char const);
  436. # define CHAR_DSP_SIZE(c)                                                    \
  437.     ( ((unsigned int)c>=' ' && (unsigned int)c<127 && c!=(unsigned char)'~') \
  438.        ? dsp.norm : char_dsp_size(c)                                         \
  439.     )
  440.   extern int txt2scr(int,int,unsigned char const*);
  441.   extern int scr2txt(int,int,unsigned char const*);
  442.   extern void x_shift(int*const,int*const,int,int,int,unsigned char const*);
  443.   extern void clrbuffline(int,int);
  444.   extern int prt_bin_text(int,int,boolean,unsigned char *);
  445.   extern int prt_highlight_bin_text(int,int,int,int,boolean,unsigned char *);
  446.   extern void move_prt_clreol(int,int,int,int,boolean,unsigned char *);
  447.   extern void write_dsp_line(element const*const,int);
  448.   extern int title_op(TITLE_OP);
  449.   extern void restore_area(void);
  450.   extern void set_area(int);
  451.   extern void write_area(int,int,unsigned char const*);
  452.   extern void restore(int);
  453.   extern void restore_to_end(int);
  454.   extern void restore_element(int);
  455.   extern void restore_or_restore_to_end(void);
  456.   extern boolean restore_shift(int);
  457.   extern void up_a_bit(int);
  458.   extern void down_a_bit(int);
  459.   extern void whole_screen_up(void);
  460.   extern void whole_screen_down(void);
  461.   extern boolean upd_highlight(element*,element*,boolean);
  462.   extern unsigned char *u_modes[MODE_COUNT*2];
  463.   extern int n_modes[MODE_COUNT];
  464.   extern boolean um_active[MODE_COUNT];
  465.   extern int message_line;
  466.   extern win_data area_line;
  467.   extern int area_used;
  468.   extern dsp_data dsp;
  469.   extern boolean dirty;
  470.   extern boolean xy_show;
  471.   extern boolean allow_text_so;
  472.   extern unsigned char *w_name;
  473.   extern unsigned char print_buffer[BUFFERLEN+1];
  474. #ifdef WINDOW_TITLE_CHANGE
  475.      extern unsigned char statline[BUFFERLEN+1];
  476. #endif
  477. #endif
  478. /*}}}  */
  479. /*{{{  FIELDEDIT_C*/
  480. #if defined(FIELDEDIT_C) || defined(I_FIELDEDIT_C)
  481. # ifdef I_FIELDEDIT_C
  482. #    undef I_FIELDEDIT_C
  483. # endif
  484.   extern void move_cursor(int);
  485.   extern void restore_cursor_and_sleep(int);
  486.   extern TOKEN field_edit(void);
  487.   extern unsigned char deleted_ch;
  488.   extern void do_cc_compare(unsigned char const,TOKEN const);
  489.   extern void do_str_compare(unsigned char const * const);
  490. #endif
  491. /*}}}  */
  492. /*{{{  FILEC*/
  493. #if defined(FILEC_C) || defined(I_FILEC_C)
  494. # ifdef I_FILEC_C
  495. #     undef I_FILEC_C
  496. # endif
  497.    extern char *filec(char*);
  498. #endif
  499. /*}}}  */
  500. /*{{{  FINDS_C*/
  501. #if defined(FINDS_C) || defined(I_FINDS_C)
  502. # ifdef I_FINDS_C
  503. #    undef I_FINDS_C
  504. # endif
  505.   extern int line_no(element const*,element const*const);
  506.   extern int cur_line_no(void);
  507.   extern void close_and_open_folds(element*const);
  508.   extern void find_element(int, int);
  509.   extern boolean find_item(boolean,boolean,boolean re_args(reg_types));
  510.   extern element *pre_find_element(int);
  511.   extern void goto_line(int,element*,boolean);
  512.   extern void query_replace(boolean);
  513.   extern void do_replace(void);
  514.   extern void its_search(boolean);
  515.   extern unsigned char item_to_look_for[LINELEN+1];
  516. # ifdef REGEXP
  517.      extern boolean inverted_search;
  518. # endif
  519. #endif
  520. /*}}}  */
  521. /*{{{  FOLDFILING_C*/
  522. #if defined(FOLDFILING_C) || defined(I_FOLDFILING_C)
  523. # ifdef I_FOLDFILING_C
  524. #    undef I_FOLDFILING_C
  525. # endif
  526.   extern void save_lang(struct lg_dumb*const);
  527.   extern void reset_lang(struct lg_dumb*const);
  528.   extern void proc_language(void);
  529.   extern void file_fold(unsigned char const*const,FILE*const);
  530.   extern void attach_file(void);
  531.   extern void filter_op(boolean);
  532.   extern void pipe_from_command(void);
  533.   extern void pipe_to_command(void);
  534.   extern char *dump_file(void);
  535.   extern void save_file(boolean const);
  536.   extern void auto_write(void);
  537.   extern int add_edit_file(char const*const,int,boolean);
  538.   extern unsigned char const *fileno2name(int);
  539.   extern void gen_arg_list(element*,element*);
  540.   extern void open_arg_list(void);
  541.   extern void open_file(boolean const);
  542.   extern void open_list_file(void);
  543.   extern void enter_list_file(void);
  544.   extern void write_file(void);
  545. #endif
  546. /*}}}  */
  547. /*{{{  FOLDHELP_C*/
  548. #if defined(FOLDHELP_C) || defined(I_FOLDHELP_C)
  549. # ifdef I_FOLDHELP_C
  550. #    undef I_FOLDHELP_C
  551. # endif
  552.   extern void check_fold(element*const);
  553.   extern int to_start(int const);
  554.   extern int to_bottom(int const);
  555.   extern void skip_to(element*const);
  556.   extern void move_down(void);
  557.   extern void move_up(void);
  558.   extern void undel_before(element*const);
  559.   extern void append_to_pick(element*const);
  560.   extern void undel_pick_before(void);
  561.   extern void undel_after(element*const);
  562.   extern void pre_remove_line(element**const);
  563. #endif
  564. /*}}}  */
  565. /*{{{  FOLDING_C*/
  566. #if defined(FOLDING_C) || defined(I_FOLDING_C)
  567. # ifdef I_FOLDING_C
  568. #    undef I_FOLDING_C
  569. # endif
  570.   extern boolean normal_att(fold_data const*const,boolean);
  571.   extern void insert_link_before(element*const);
  572.   extern element *copy_a_line(void);
  573.   extern boolean chg_foldtype(int const,int const);
  574.   extern void start_make_fold(sel_mod);
  575.   extern void make_fold(void);
  576.   extern void remove_line(element**const);
  577.   extern void delete_list(element*,element*const);
  578.   extern void pre_exit_fold(void);
  579.   extern void pre_top_fold(void);
  580.   extern void pre_open_fold(element*const);
  581.   extern void enter_fold(unsigned char const*const);
  582.   extern void exit_fold(void);
  583.   extern void open_fold(void);
  584.   extern void close_fold(void);
  585.   extern void unfold(void);
  586.   extern void create_list(void);
  587.   extern void chg_marks(void);
  588.   extern element *pick_head;
  589.   extern element *pick_tail;
  590.   extern unsigned char cur_dsp_line[LINELEN+1];
  591. #endif
  592. /*}}}  */
  593. /*{{{  GETMSG_C*/
  594. #if defined(GETMSG_C) || defined(I_GETMSG_C)
  595. # ifdef I_GETMSG_C
  596. #    undef I_GETMSG_C
  597. # endif
  598.   extern unsigned char *i_to_ua(int);
  599.   extern unsigned char *get_msg(msgtyp,...);
  600.   extern int msg_file;
  601.   extern unsigned char **rc_msg;
  602.   extern int rc_msg_count;
  603.   extern msgtyp last_message;
  604. #endif
  605. /*}}}  */
  606. /*{{{  GETTK_C*/
  607. #if defined(GETTK_C) || defined(I_GETTK_C)
  608. # define cy_ind  (a_f_mac[1])
  609. #  ifndef OCL_DEBUG
  610. #     define get_arg(s) get_argument()
  611. #     define get_arg_fixed(c,s) get_argument_fixed(c)
  612. #  endif
  613. #endif
  614. #if defined(GETTK_C) || defined(I_GETTK_C)
  615. # ifdef I_GETTK_C
  616. #    undef I_GETTK_C
  617. # endif
  618.   /*{{{  macro_entry*/
  619.   typedef struct
  620.    { enum { load=0,loaded,init,def } mode;
  621.      union { TOKEN const *txt;off_t off; } mac;
  622.    } macro_entry;
  623.   /*}}}  */
  624.   /*{{{  stackent*/
  625.   typedef union { TOKEN const *tp;int v;element *l; } stackent;
  626.   /*}}}  */
  627.   extern void ori_abort(int sig);
  628.   extern void stop_macros(boolean);
  629.   extern boolean push_macro(TOKEN const*const);
  630.   extern TOKEN const *push_str_macro(unsigned char const*);
  631.   extern void auto_flush(void);
  632. # ifndef OCL_DEBUG
  633.      extern TOKEN get_argument(void);
  634.      extern TOKEN get_argument_fixed(int);
  635. # else
  636.      extern TOKEN get_arg(char const*const);
  637.      extern TOKEN get_arg_fixed(int,char const*const);
  638. # endif
  639.   extern void call_number_macro(int);
  640.   extern void prompt_string(unsigned char*);
  641.   extern TOKEN hide_key(void);
  642.   extern TOKEN edit_key(void);
  643.   extern TOKEN const empty_macro[];
  644.   extern TOKEN a_f_mac[];
  645.   extern int bind_const[RCC_SIZE];
  646.   extern macro_entry const *fix_macros;
  647.   extern boolean macro_tag;
  648.   extern boolean run_abort_mac;
  649.   extern stackent *ocl_var;
  650.   extern int executing_macro;
  651.   extern boolean defining_macro;
  652.   extern int scr_off;
  653. #endif
  654. /*}}}  */
  655. /*{{{  INIT_C*/
  656. #if defined(INIT_C) || defined(I_INIT_C)
  657. # ifdef I_INIT_C
  658. #    undef I_INIT_C
  659. # endif
  660.   extern char *open_sysfile(char const*const,char*const);
  661.   extern boolean rcfileparser(char[NO_OCL_CMD_OPTS*(2*BIND_NAME_LEN+2)],char*);
  662.   extern TOKEN const *load_demand(int const);
  663.   extern void unload_demand(int const);
  664.   extern void HostBegin(char*);
  665.   extern void initialise(void);
  666.   extern void rcclose(void);
  667.   extern FILE *rcfile;
  668.   extern char *ori_name;
  669. # ifdef NOMEMDUMP
  670.     extern char *mem_dump_malloc;
  671. # endif
  672.   extern off_t helpofs;
  673.   extern off_t compofs;
  674.   extern char const *ori_path;
  675. #endif
  676. /*}}}  */
  677. /*{{{  KEYBOARD_C*/
  678. #if defined(KEYBOARD_C) || defined(I_KEYBOARD_C)
  679. # ifdef I_KEYBOARD_C
  680. #    undef I_KEYBOARD_C
  681. # endif
  682.   extern void enable_echo(boolean const);
  683.   extern void switch_echo(boolean const);
  684.   extern void enable_abort(void);
  685.   extern void disable_abort(void);
  686.   extern void init_keyboard(void);
  687.   extern void reset_keyboard(void);
  688. # ifdef WINDOW_TITLE_CHANGE
  689.      extern void chg_w_title(char const*);
  690. # endif
  691.   extern void read_err(FILE * const f,char * const s);
  692.   extern TOKEN get_key(void);
  693.   extern FILE *kbd_file;
  694.   extern boolean echo_disabled;
  695.   extern boolean echo_active;
  696.   extern boolean eight_bits;
  697. # ifdef WINDOW_TITLE_CHANGE
  698.      extern char *w_title;
  699.      extern int wt_buff_id;
  700. # endif
  701. # ifdef MOUSY
  702.      extern mouse_typ use_mouse;
  703.      extern const int mouse_b_count[mouse_supports];
  704.      extern char const * const * const mouse_b_names[mouse_supports];
  705. # endif
  706. #endif
  707. /*}}}  */
  708. /*{{{  KEYTAB_C*/
  709. #if defined(KEYTAB_C) || defined(I_KEYTAB_C)
  710. # ifdef I_KEYTAB_C
  711. #    undef I_KEYTAB_C
  712. # endif
  713.   extern void kbd_change(int const);
  714. # ifdef INIT_C
  715.      extern void set_key_top(KEY const*const,int const*const);
  716. # endif
  717.   extern int find_key(int const);
  718.   extern boolean valid_key(TOKEN const);
  719.   extern boolean valid_field_key(TOKEN const);
  720.   extern int valid_screen_key(TOKEN const);
  721.   extern boolean invalid_prompt_key(TOKEN const);
  722. # ifdef MOUSY
  723.     extern TOKEN handle_click(int const,int const,int const);
  724. # endif
  725.   extern int curr_kbd;
  726. # ifdef MOUSY
  727.     extern TOKEN *mouse_mapping;
  728. # endif
  729.   extern int const *bind_mark;
  730.   extern boolean quote_used;
  731.   extern int mouse_number;
  732. #endif
  733. /*}}}  */
  734. /*{{{  LOOP_C*/
  735. #if defined(LOOP_C) || defined(I_LOOP_C)
  736. # ifdef I_LOOP_C
  737. #    undef I_LOOP_C
  738. # endif
  739.   extern void warn_mult_edit(void);
  740.   extern RETURNS main_editor_loop(void);
  741.   extern int decode_buffer_mouse(int const,int const,boolean const);
  742.   extern void mail_and_dump(int);
  743.   extern unsigned char line_buffer[LINELEN+1];
  744.   extern FILE *start_pipe;
  745.   extern boolean running;
  746.   extern buffer_data bd;
  747.   extern buffer_data init_buffer;
  748.   extern int buff_used;
  749.   extern int mult_edit;
  750.   extern win_data root_dont_use;
  751.   extern int startup_line;
  752.   extern boolean no_fold_out;
  753. #endif
  754. /*}}}  */
  755. /*{{{  MAIN_C*/
  756. #if defined(MAIN_C) || defined(I_MAIN_C)
  757. # ifdef I_MAIN_C
  758. #    undef I_MAIN_C
  759. # endif
  760.   extern char kp_state;
  761.   extern char const *rc_name;
  762.   extern unsigned char const *filearg;
  763.   extern boolean auto_save;
  764.   extern TOKEN sig_macro[HISTORY_SIZE+1];
  765.   extern int sig_count;
  766.   extern boolean verbose;
  767.   extern boolean aborted;
  768. # if defined(SIGWINCH) || defined(MGR)
  769.     extern boolean win_changed;
  770. # endif
  771.   extern boolean interrupt_restore;
  772.   extern element null_element;
  773.   extern language_comment dialects[F_C_SIZE];
  774.   extern boolean no_suspend;
  775.   extern boolean no_pipe;
  776. #endif
  777. /*}}}  */
  778. /*{{{  MESSAGES_C*/
  779. #if defined(MESSAGES_C) || defined(I_MESSAGES_C)
  780. # ifdef I_MESSAGES_C
  781. #    undef I_MESSAGES_C
  782. # endif
  783.   /*{{{  inputs*/
  784.   extern unsigned char NO;
  785.   extern unsigned char YES;
  786.   extern unsigned char AB;
  787.   extern unsigned char DO_AB;
  788.   extern unsigned char DO_REST;
  789.   /*}}}  */
  790.   /*{{{  not getmsg messages*/
  791.   extern unsigned char origami_name[BIND_NAME_LEN+1];
  792.   extern unsigned char const ctrl_decode[];
  793.   extern unsigned char const hex_digits[];
  794.   extern char const M_FM[];
  795.   extern char const M_INV_OCL[];
  796.   extern unsigned char const M_MIS_MES[];
  797.   extern unsigned char const M_IN_MES[];
  798.   extern unsigned char const M_NO_MEMORY[];
  799.   extern unsigned char const M_NO_MALLOC[];
  800.   extern unsigned char const M_INVALID_PATH[];
  801.   /*}}}  */
  802.   /*{{{  parts of filenames*/
  803.   extern unsigned char const M_CUT_PATH[];
  804.   extern char const M_RCSTR[];
  805.   extern char const M_MSGSTR[];
  806.   extern char const M_HELPSTR[];
  807.   /*}}}  */
  808.   /*{{{  code folds*/
  809.   extern unsigned char const fold_f[];
  810.   extern unsigned char const fold_a[];
  811.   /*}}}  */
  812.   /*{{{  multiple used text*/
  813.   extern unsigned char const question[];
  814. #  if FOLD_TAG_LENGTH>=3
  815.      extern const unsigned char pseudo_mark[];
  816. #    define three_space (pseudo_mark+FOLD_TAG_LENGTH-3)
  817. #  else
  818.      extern const unsigned char three_space[];
  819. #    define pseudo_mark (three_space+3-FOLD_TAG_LENGTH)
  820. #  endif
  821. #  define two_space (three_space+1)
  822. #  define one_space (three_space+2)
  823. #  define empty_text (three_space+3)
  824.   extern unsigned char const M_PSTR[];
  825.   /*}}}  */
  826.   /*{{{  paths*/
  827. #  ifdef DOC_MSG
  828.      extern char const M_DOC_PATH[];
  829. #  endif
  830.   extern char const M_RC_PATH[];
  831.   /*}}}  */
  832.   /*{{{  missing functions*/
  833. #  ifndef REGEXP
  834.      extern unsigned char const M_NOT_HERE[];
  835. #  endif
  836.   /*}}}  */
  837. # ifndef NO_MSG
  838.      extern boolean copyright;
  839. # endif
  840.   /*{{{  copyright/usage string access*/
  841.   extern unsigned char const *get_copyright(boolean);
  842.   extern unsigned char const *get_long_usage(void);
  843.   extern unsigned char const M_S_USAGE[];
  844. #  define get_short_usage() M_S_USAGE
  845.   /*}}}  */
  846. #endif
  847. /*}}}  */
  848. /*{{{  MISC_C*/
  849. #if defined(MISC_C) || defined(I_MISC_C)
  850. # ifdef I_MISC_C
  851. #    undef I_MISC_C
  852. # endif
  853.   extern unsigned char *fileprompt(unsigned char * const);
  854.   extern void put_vars(void);
  855.   extern void ocl_screen_off(void);
  856.   extern boolean ocl_screen_on(void);
  857. #endif
  858. /*}}}  */
  859. /*{{{  ORIEDT_C*/
  860. #if defined(ORIEDT_C) || defined(I_ORIEDT_C)
  861. # ifdef I_ORIEDT_C
  862. #    undef I_ORIEDT_C
  863. # endif
  864.   extern void *ori_malloc(size_t);
  865.   extern void spaces(unsigned char*, int);
  866.   extern void proc_dispose(element*const);
  867.   extern void trailing_spaces(unsigned char*);
  868.   extern void join_links(element*const,element*const);
  869.   extern element *move_on(element const*);
  870.   extern void close_fold_at(element*const);
  871.   extern element *proc_new_element(void);
  872.   extern void set_fold_mark_dsp_length(struct f_m_str*const);
  873.   extern void proc_to_edit_pos(void);
  874.   extern void proc_from_edit_pos(void);
  875.   extern void copyin(unsigned char*const,const element*const,const boolean);
  876.   extern void copyout(unsigned char const*const, element*const);
  877. #endif
  878. /*}}}  */
  879. /*{{{  PROMPT_C*/
  880. #if defined(I_PROMPT_C) || defined(PROMPT_C)
  881. # define START_HISTORY_INDEX -1
  882. # define HISTORY_ADD_OLD 1
  883. # define HISTORY_ADD_NEW -1
  884. # define s_readprompt(s,p,l,h) readprompt((s),(p),(l),(h),(unsigned char*)0,0)
  885. #endif
  886. #if defined(PROMPT_C) || defined(I_PROMPT_C)
  887. # ifdef I_PROMPT_C
  888. #    undef I_PROMPT_C
  889. # endif
  890.   extern histories overwrite_history_id;
  891.   extern void shrink_history(void);
  892.   extern void add_history(histories const,unsigned char const*const);
  893.   extern void access_history
  894.    ( int,
  895.      histories,
  896.      boolean,
  897.      int*const,
  898.      unsigned char**const
  899.    );
  900.   extern boolean show_string(unsigned char const*,boolean const);
  901.   extern void help(boolean);
  902.   extern void readprompt
  903.    ( unsigned char*const,
  904.      unsigned char const*const,
  905.      int const,
  906.      histories const,
  907.      unsigned char const*const,
  908.      int
  909.    );
  910.   extern int menu_item(unsigned char const*,int,boolean const,boolean const);
  911.   extern boolean yes(unsigned char const*const);
  912.   extern void message(unsigned char const*const);
  913.   extern void msg_message(msgtyp);
  914.   extern void verbose_msg_message(msgtyp);
  915.   extern void err_message(msgtyp,unsigned char const*const);
  916.   extern void warn_message(unsigned char const*const);
  917.   extern void no_message(void);
  918.   extern unsigned char const *menu_string;
  919.   extern int menu_current;
  920.   extern int prompt_shift_size;
  921. #endif
  922. /*}}}  */
  923. /*{{{  SCREEN_C*/
  924. #ifdef I_SCREEN_C
  925. # undef I_SCREEN_C
  926.   /*{{{  SCR_BUFF stuff, link screen access to buffer*/
  927. #  if defined(USE_SCRBUFF) && !defined(SCRBUFF_C)
  928.      /*{{{  define screen functions ??? to scrbuff functions B_???*/
  929.      /*{{{  oputs*/
  930. #     ifdef oputs
  931. #       undef oputs
  932. #     endif
  933. #     define oputs B_oputs
  934.      extern void B_oputs(unsigned char*);
  935.      /*}}}  */
  936.      /*{{{  oputc*/
  937. #     ifdef oputc
  938. #       undef oputc
  939. #     endif
  940. #     define oputc B_oputc
  941.      extern void oputc(int);
  942.      /*}}}  */
  943.      /*{{{  oflush*/
  944. #     ifdef oflush
  945. #       undef oflush
  946. #     endif
  947. #     define oflush B_oflush()
  948.      extern void B_oflush(void);
  949.      /*}}}  */
  950.      /*{{{  move_cursor_to*/
  951. #     ifdef move_cursor_to
  952. #       undef move_cursor_to
  953. #     endif
  954. #     define move_cursor_to B_move_cursor_to
  955.      /*}}}  */
  956.      /*{{{  moveclreol*/
  957. #     ifdef moveclreol
  958. #       undef moveclreol
  959. #     endif
  960. #     define moveclreol B_moveclreol
  961.      /*}}}  */
  962.      /*{{{  ClrScr*/
  963. #     ifdef ClrScr
  964. #       undef ClrScr
  965. #     endif
  966. #     define ClrScr B_ClrScr
  967.      /*}}}  */
  968.      /*{{{  insLine*/
  969. #     ifdef insLine
  970. #       undef insLine
  971. #     endif
  972. #     define insLine B_insLine
  973.      /*}}}  */
  974.      /*{{{  DelLine*/
  975. #     ifdef DelLine
  976. #       undef DelLine
  977. #     endif
  978. #     define DelLine B_DelLine
  979.      /*}}}  */
  980.      /*{{{  do_standout*/
  981. #     ifdef do_standout
  982. #       undef do_standout
  983. #     endif
  984. #     define do_standout B_do_standout
  985.      /*}}}  */
  986.      /*{{{  do_standend*/
  987. #     ifdef do_standend
  988. #       undef do_standend
  989. #     endif
  990. #     define do_standend B_do_standend
  991.      /*}}}  */
  992.      /*{{{  init_terminal*/
  993. #     ifdef init_terminal
  994. #       undef init_terminal
  995. #     endif
  996. #     define init_terminal B_init_terminal
  997.      /*}}}  */
  998.      /*{{{  reset_terminal*/
  999. #     ifdef reset_terminal
  1000. #       undef reset_terminal
  1001. #     endif
  1002. #     define reset_terminal B_reset_terminal
  1003.      /*}}}  */
  1004.      /*{{{  get_terminal_capability*/
  1005. #     ifdef get_terminal_capability
  1006. #       undef get_terminal_capability
  1007. #     endif
  1008. #     define get_terminal_capability B_get_terminal_capability
  1009.      /*}}}  */
  1010.      /*{{{  xs*/
  1011. #     ifdef xs
  1012. #       undef xs
  1013. #     endif
  1014. #     define xs B_xs
  1015.      /*}}}  */
  1016.      /* bell,bell_visible,screen_off,screen_on are used directly! */
  1017.      /*}}}  */
  1018.      extern void B_invalid(void);
  1019.      extern void B_valid(void);
  1020. #  endif
  1021. #  ifdef USE_SCRBUFF
  1022. #    ifndef BLOCK_FLUSH
  1023.         extern void step_or_move_cursor(int,int,int,int);
  1024.         extern void insChar(unsigned char*,int);
  1025.         extern void delChar(int);
  1026.         extern int moputc(int,int);
  1027.         extern boolean use_shift;
  1028.         extern boolean mi;
  1029. #    else
  1030. #       define use_shift FALSE
  1031. #       define step_or_move_cursor(y,x,dy,dx) move_cursor_to(y,x)
  1032. #    endif
  1033.      extern void scr_cursor(boolean);
  1034.      extern boolean B_scroll_region(int,int,int,int,boolean);
  1035. #    ifdef EXT_SCRBUFF_ACCESS
  1036.         extern unsigned char cur_scr_char(int,int);
  1037. #    endif
  1038.      extern boolean am;
  1039.      extern char const *ce;
  1040. #  else
  1041. #    define B_invalid() 0
  1042. #    define B_valid() 0
  1043. #    define B_scroll_region(y1,x1,y2,x2,up) TRUE
  1044. #  endif
  1045.   /*}}}  */
  1046.   extern void move_cursor_to(int,int);
  1047.   extern void moveclreol(int,int);
  1048.   extern void ClrScr(void);
  1049.   extern boolean insLine(int);
  1050.   extern boolean DelLine(int);
  1051.   extern void do_standout(void);
  1052.   extern void do_standend(void);
  1053.   extern void init_terminal(void);
  1054.   extern void reset_terminal(void);
  1055.   extern void bell_visible(void);
  1056.   extern void bell_audible(void);
  1057.   extern void send_terminal(int);
  1058. # define send_s_terminal(s) \
  1059.      do { unsigned char *p;for (p=(s);*p;send_terminal(*p++));} while(NEVER)
  1060.   extern void flush_terminal(void);
  1061.   extern boolean check_terminal(char const * const);
  1062.   extern void screen_off(void);
  1063.   extern void screen_on(void);
  1064.   extern int get_terminal_capability(void);
  1065.   extern char const *terminal;
  1066.   extern FILE *scrout;
  1067.   extern char const *al;
  1068.   extern char const *dl;
  1069.   extern boolean xs;
  1070.   extern boolean xt;
  1071.   extern boolean hz;
  1072.   extern int sg;
  1073.   extern char const *so;
  1074.   extern win_data screen;
  1075. #endif
  1076. /*}}}  */
  1077. /*{{{  SET_C*/
  1078. #if defined(SET_C) || defined(I_SET_C)
  1079. # ifdef I_SET_C
  1080. #    undef I_SET_C
  1081. # endif
  1082. # if defined(SET_C) || defined(FIELDEDIT_C)
  1083.      extern boolean test_char_set(int,SetId);
  1084. # endif
  1085.   extern void set_copy(int,int);
  1086.   extern boolean init_set(void);
  1087. #endif
  1088. /*}}}  */
  1089. /*{{{  SHELL_C*/
  1090. #if defined(SHELL_C) || defined(I_SHELL_C)
  1091. # ifdef I_SHELL_C
  1092. #    undef I_SHELL_C
  1093. # endif
  1094.   extern int subshell(const char*const);
  1095.   extern FILE *open_shell(const char*const,const char*const);
  1096.   extern int close_shell(FILE*);
  1097.   extern boolean force_sh;
  1098.   extern boolean secure;
  1099.   extern char const *shell_name;
  1100. #endif
  1101. /*}}}  */
  1102. /*{{{  SIGNALS_C*/
  1103. #if defined(SIGNALS_C) || defined(I_SIGNALS_C)
  1104. # ifdef I_SIGNALS_C
  1105. #    undef I_SIGNALS_C
  1106. # endif
  1107.   extern void exit_origami(RETURNS,unsigned char const*);
  1108.   extern void check_time_event(void);
  1109.   extern void init_signals(void);
  1110.   extern int switch_time(boolean);
  1111.   extern void set_alarm(int,boolean);
  1112.   extern void reset_alarm(void);
  1113.   extern void suspend(void);
  1114.   extern int alarm_time;
  1115.   extern char time_str[];
  1116.   extern boolean do_dump;
  1117. # ifdef USE_SCRBUFF
  1118.     extern boolean redraw_on_sig;
  1119. #else
  1120. #   define redraw_on_sig True
  1121. # endif
  1122. #endif
  1123. #ifdef SIGNALS_C
  1124. # ifdef AUTOSAVE_FILE
  1125.     extern boolean autosave_done;
  1126. # endif
  1127. #endif
  1128. /*}}}  */
  1129. /*{{{  READFOLDS_C*/
  1130. #if defined(READFOLDS_C) || defined(I_READFOLDS_C)
  1131. # ifdef I_READFOLDS_C
  1132. #    undef I_READFOLDS_C
  1133. # endif
  1134.   extern void insert_file
  1135.    ( element const*const,
  1136.      element*const,
  1137.      element*const,
  1138.      boolean const,
  1139.      element const*const,
  1140.      boolean*const,
  1141.      boolean*const,
  1142.      FILE*const
  1143.    );
  1144.   extern struct f_sz { int c;int l; } file_io_size;
  1145. #endif
  1146. /*}}}  */
  1147. /*{{{  VIRTUAL_C*/
  1148. #if defined(VIRTUAL_C) || defined(I_VIRTUAL_C)
  1149. # ifdef I_VIRTUAL_C
  1150. #    undef I_VIRTUAL_C
  1151. # endif
  1152. # ifdef VIRTUAL
  1153.     extern int init_data_handle(void);
  1154.     extern int end_data_handle(void);
  1155. # endif
  1156.   extern void set_data
  1157.    ( element *const,
  1158.      unsigned char const*const,
  1159.      boolean const txt
  1160.    );
  1161.   extern void set_0_data(element *const);
  1162. # ifdef VIRTUAL
  1163.     extern unsigned char *get_data(element const*const);
  1164.     extern void new_data(element*);
  1165.     extern int vir_nodes;
  1166. # else
  1167. #    define get_data(p) (p)->datas.dat
  1168. #    define new_data(p) (p)->datas.dat=(unsigned char*)empty_text
  1169. # endif
  1170. #endif
  1171. /*}}}  */
  1172. /*{{{  WRITEFOLDS_C*/
  1173. #if defined(WRITEF_C) || defined(I_WRITEF_C)
  1174. # ifdef I_WRITEF_C
  1175. #    undef I_WRITEF_C
  1176. # endif
  1177.   extern boolean write_fold(unsigned char const*const,element const*const,FILE*const);
  1178.   extern void total_save(FILE*const);
  1179.   extern int current_ind;
  1180. #endif
  1181. /*}}}  */
  1182.